<template>
  <div class="onTheScale">
    <div class="left">
      <div class="box">
        <div class="top">规上工业增加值</div>
        <div class="bottom">
          <div class="light-bg">
            <img
              src="@/assets/industrialOperation/red-rise.png"
              class="img"
              alt=""
            />
            <span class="val">
              <CountTo
                :startVal="0"
                :endVal="10.2"
                :decimals="1"
                :duration="1000"
            /></span>
            <span class="unit"> {{ '%' }}</span>
          </div>
          <div class="info">
            <div class="span">全省排名第 2 名</div>
            <div class="span">7市排名第 2 名</div>
          </div>
        </div>
      </div>
      <div class="box">
        <div class="top">规上工业营收收入</div>
        <div class="bottom">
          <div class="info left-info">
            <div class="span">
              <span class="num">
                <CountTo :startVal="0" :endVal="9232" :duration="1000" /> </span
              >亿元
            </div>
            <div class="span">
              <img
                src="@/assets/industrialOperation/red-rise.png"
                class="img"
                alt=""
              />
              <span class="val">
                <CountTo
                  :startVal="0"
                  :endVal="10.2"
                  :decimals="1"
                  :duration="1000"
              /></span>
              <span class="unit"> {{ '%' }}</span>
            </div>
          </div>
          <div class="info">
            <div class="span">总量排名第<span class="num">3</span>名</div>
            <div class="span">增速排名第<span class="num">8</span>名</div>
          </div>
        </div>
      </div>
    </div>
    <div class="right">
      <div class="top-box">全国各行业规上工业增加值累计增速情况</div>
      <div id="chart1" class="chart-box"></div>
    </div>
  </div>
</template>
<script>
import * as echarts from 'echarts'
import CountTo from 'vue-count-to'
export default {
  components: {
    CountTo
  },
  data() {
    return {}
  },
  mounted() {
    this.initFun()
  },
  methods: {
    async initFun() {
      this.xAxisData = ['采矿业', '制造业', '电力热...']
      let option = {
        legend: {
          show: false
        },
        tooltip: {
          trigger: 'axis',
          extraCssText:
            'background: #fff; border-radius: 0;box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);color: #333;',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: {
          top: '15%',
          left: '0%',
          right: '0%',
          bottom: '5%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: true,
            axisLabel: {
              textStyle: {
                color: '#F2F6FF'
              }
            },
            axisTick: {
              show: false // 不显示坐标轴刻度线
            },
            axisLine: {
              lineStyle: {
                color: '#00BAFF'
              }
            },
            data: this.xAxisData
          }
        ],
        yAxis: [
          {
            name: '单位: %',
            type: 'value',
            axisLabel: {
              textStyle: {
                color: '#F2F6FF'
              }
            },
            nameTextStyle: {
              color: '#F2F6FF',
              fontSize: 12,
              padding: 0
            },
            splitLine: {
              lineStyle: {
                type: 'solid',
                color: '#1E4469'
              }
            },
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            }
          }
        ],
        series: [
          {
            name: '',
            type: 'bar',
            showBackground: true, // 柱状背景
            data: [15, 9, 5],
            barWidth: 24, // 柱子宽度
            barGap: 0.5, // 柱子之间间距
            itemStyle: {
              normal: {
                color: 'rgba(84, 143, 218, 1)'
              }
            }
          }
        ]
      }
      const lineObj = echarts.init(document.getElementById('chart1'))
      lineObj.setOption(option)
    }
  }
}
</script>
<style lang="scss" scoped>
.onTheScale {
  display: flex;
  gap: 11px;
  .left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    .box {
      height: 113px;
      background: rgba(43, 101, 156, 0.36);
      border-radius: 5px 5px 5px 5px;
      border: 1px solid #2b659c;
      padding: 6px 0;
      padding-bottom: 0px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .top {
        width: 100%;
        height: 40px;
        background: url('~@/assets/industrialOperation/c-bg1.png') center
          center/cover;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: MicrosoftYaHeiUI;
        font-size: 16px;
        color: #ffffff;
      }
      .bottom {
        display: flex;
        flex: 1;
        padding: 5px 0;
        .light-bg {
          width: 94px;
          height: 55px;
          background: url('~@/assets/industrialOperation/light-bg.png') center
            center/cover;
          text-align: center;
          padding-top: 7px;
          .img {
            width: 14px;
            height: 18px;
          }
          .val {
            font-family: MicrosoftYaHeiUI;
            font-size: 16px;
            color: red;
            font-weight: bold;
          }
          .unit {
            font-family: MicrosoftYaHeiUI;
            font-size: 14px;
            color: red;
          }
        }
        .left-info {
          .span {
            .img {
              width: 14px;
              height: 18px;
            }
            .val {
              font-family: MicrosoftYaHeiUI;
              font-size: 16px;
              color: red;
              font-weight: bold;
            }
            .unit {
              font-family: MicrosoftYaHeiUI;
              font-size: 14px;
              color: red;
            }
          }
        }
        .info {
          flex: 1;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: space-around;
          font-family: MicrosoftYaHeiUI;
          font-size: 14px;
          color: #ffffff;
          .num {
            font-size: 16px;
            font-weight: bold;
          }
        }
      }
    }
  }
  .right {
    flex: 1;
    display: flex;
    flex-direction: column;
    .top-box {
      width: 217px;
      height: 55px;
      background: url('~@/assets/industrialOperation/c-bg2.png') center
        center/cover;
      font-family: MicrosoftYaHeiUI;
      font-size: 16px;
      color: #ffffff;
      padding: 6px 14px;
      font-weight: bold;
    }
    .chart-box {
      flex: 1;
      margin-top: 5px;
    }
  }
}
</style>
